package cn.edu.lingnan.service.book;


import cn.edu.lingnan.bean.Book;
import cn.edu.lingnan.service.base.BaseService;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

import java.util.List;
import java.util.Map;
import java.util.Optional;

@CacheConfig(cacheNames = "springboot")
public interface BookService {

    //分页条件查询
    @CachePut(keyGenerator = "keyGenerator")
    Map<String, Object> page(int pageNum, int pageSize, String entity);

    //分页查询
    Map<String, Object> page(int pageNum, int pageSize);

    //查询所有
    List<Book> selectAll();

    //根据主键查询
    Optional<Book> selectById(Object id);

    //保存
    Book save(Book entity);

    //批量更新
    List<Book> saveBatch(List<Book> entity);

    //删除对象
    @CacheEvict(keyGenerator = "keyGenerator")
    void deleteById(int id);

    //批量删除
    void deleteBatch(String[] ids);

    //更新
    @CachePut(keyGenerator = "keyGenerator")
    Book update(Book entity, Object id);

}
